package com.polaris.live.viewmodel

import androidx.lifecycle.MutableLiveData
import com.polaris.live.common.mvvm.viewmodel.BaseViewModel
import com.polaris.live.common.network.requestLoading
import com.polaris.live.common.network.state.ResultState
import com.polaris.live.net.userService
import com.polaris.live.resp.go_resp.VipBuyRequest
import com.polaris.live.resp.go_resp.VipInstallRequest

/**
 * VipCenterViewModel
 *
 * @author Created by 天晴 on 2024/12/10/022 16:01
 */
class VipCenterOwnViewModel : BaseViewModel() {

    //购买
    val vipBuyLiveData = MutableLiveData<ResultState<VipBuyRequest>>()
    fun vipBuy(vipLevel: Long, otherUserId: Long? = null) {
        val request = VipBuyRequest(otherUserId, vipLevel)
        requestLoading({ userService.vipBuy(request) }, {
            vipBuyLiveData.value = ResultState.onAppSuccess(request)
        }, {
            vipBuyLiveData.value = ResultState.onAppError(it)
        })
    }

    //安装装扮
    val vipInstallLiveData = MutableLiveData<ResultState<Any>>()
    fun vipInstall(vipLevel: Long) {
        requestLoading({ userService.vipInstall(VipInstallRequest(true, vipLevel)) }, vipInstallLiveData)
    }
}